const user = {
  state: {
    userName:
      localStorage.getItem("userName") &&
      JSON.parse(localStorage.getItem("userName")),
    avatar:
      (localStorage.getItem("avatar") &&
        JSON.parse(localStorage.getItem("avatar"))) ||
      "https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png",
    userId:
      localStorage.getItem("userId") &&
      JSON.parse(localStorage.getItem("userId"))||1,
    userType:
      localStorage.getItem("userType") &&
      JSON.parse(localStorage.getItem("userType")), //0游客1员工2部门负责人3管理者
    userDept:
      localStorage.getItem("userDept") &&
      JSON.parse(localStorage.getItem("userDept")),
  },
  mutations: {
    setUserName: (state, userName) => {
      state.userName = userName;
    },
    setAvatar: (state, avatar) => {
      state.avatar = avatar;
    },
    setUserId: (state, userId) => {
      state.userId = userId;
    },
    setUserType: (state, userType) => {
      state.userType = userType;
    },
    setUserDept: (state, userDept) => {
      state.userDept = userDept;
    },
  },
};

export default user;
